package gold.digger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC522 {
    public long startExecuteTime = System.currentTimeMillis();


    public class Solution {
        public boolean isSubsequence(String x, String y) {
            int j = 0;
            for (int i = 0; i < y.length() && j < x.length(); i++)
                if (x.charAt(j) == y.charAt(i))
                    j++;
            return j == x.length();
        }

        public int findLUSlength(String[] strs) {
            Arrays.sort(strs, new Comparator<String>() {
                public int compare(String s1, String s2) {
                    return s2.length() - s1.length();
                }
            });
            for (int i = 0, j; i < strs.length; i++) {
                boolean flag = true;
                for (j = 0; j < strs.length; j++) {
                    if (i == j)
                        continue;
                    if (isSubsequence(strs[i], strs[j])) {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                    return strs[i].length();
            }
            return -1;
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC522 an = new LC522();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
